﻿/// ---------------------------------------------
///
/// 蔡龙丰
/// 2014/6/26
///
/// ---------------------------------------------

///----------------------------------------------
///双击事件
///----------------------------------------------
function CustomDbClick() {
    parent.closeWin(); //去掉双击功能
    //fnCustomEdit();
}
///----------------------------------------------

///添加
var fnCustomAdd = function () {
    document.getElementById("dialog1_h").innerHTML = "添加通讯录信息";
    document.getElementById("EditUIWindow").src = "AutoLoadForm.aspx?r=" + Math.random() + "&entity=hrEmployeeContacts";
    SetDWH(450, 300, YAHOO.example.container.dialog1);
    YAHOO.example.container.dialog1.show();
}
///修改
var fnCustomEdit = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }

    var checkNum = record.getData("checkNum");
    if (checkNum == "0") {
        document.getElementById("dialog1_h").innerHTML = "修改通讯录信息";
        document.getElementById("EditUIWindow").src = "AutoLoadForm.aspx?r=" + Math.random() + "&entity=hrEmployeeContacts&id=" + record.getData(const_entityID);
        SetDWH(450, 300, YAHOO.example.container.dialog1);
        YAHOO.example.container.dialog1.show();
        RefreshData();
    } else {
        const_EditEntity = "hrEmployee";
        var deptName = record.getData("DepartmentName");
        var postName = record.getData("PostNames");
        var pagetitle = "修改在职员工信息—" + record.getData("CName");
        parent._employeeTitle = pagetitle;

        parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID) + "&deptName=" + deptName + "&postName=" + postName + "&type=1"));
        parent.NeedRefreshPage = this;
    }
}

//删除
var fnCustomDelete = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);

    var checkNum = record.getData("checkNum");
    if (checkNum == "0") {
        const_EditEntity = "hrEmployeeContacts";
        SaveUrl = "../Extend/AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID);
        YAHOO.example.container.dialog3.show();
    } else {
        alert("该信息不能被删除，请去在职管理中修改");
    }
}

var fnAddEduHistory = function () {
}

if (typeof ($) != "undefined") {
    $(document).ready(function () {
        try {
            if (getPar1('id') == "") {
                //alert(parent.parent.getPar1('id'));
                instance[0].EmployeeID = parent.parent.getPar1('id');
            }
        } catch (e)
        { }
    });
}

//获取所有的部门及它的编码
//放弃
function getDpmNameAll(departmentName) {
    try {
        //var url = encodeURI("../../Extend/AjaxData/jsonlist.aspx?entity=V_hrEmployee&condition=ID='" + empId + "'";
        var url = "../../Crm/BSendSysNews.ashx?num=t&ID=" + departmentName + "&r=" + Math.random();
        $.get(url, function (d, s) {
            var list = eval("(" + d + ")");
            var info = "";
            for (var o in list.rows) {
                var v = list.rows[o].name;
                var t = list.rows[o].code;
                if (typeof (t) != "undefined") {
                    if (v == "") {
                        v = "公司领导";
                    }
                    info += v + "(" + t + ")；";
                    //$("#DepartmentCode").val(t);
                    //$("#DepartmentName").val(t);
                    //$("#DepartmentName").append("<option value='" + t + "'>" + v + "</option>");
                }
            }
            info += "<br/>注：<span style='color:red'>公司领导</span>的<span style='color:red'>部门名称</span>不填";
            $("#wolf").html(info);
        });
    } catch (e) {
        alert(e.ToString());
    }
}


var fnCheckData = function () {

}